package com.znh.entity;

import com.znh.enums.PieceActionEnum;
import com.znh.enums.PieceInitLocationEnum;
import com.znh.enums.PiecePlayerEnum;

import java.awt.*;

/**
 * @version 1.0
 * @Author znh
 * @Date 2024/5/24 下午3:26
 * @注释 相/象类
 */
public class Xiang extends Piece {
    public Xiang(int id, Point point, PiecePlayerEnum player, PieceInitLocationEnum initLocation) {
        super(id, "xiang", point, player, initLocation, new StringBuilder().append("images/xiang")
                .append(player == PiecePlayerEnum.RED ? "0" : "1").append(".png").toString());
    }

    @Override
    public boolean isMove(Point tp) {
        PieceActionEnum action = action(tp);
        //是否走田字（正斜线、走2步）、是否蹩脚、是否过河
        return action == PieceActionEnum.FORWARDSLASH
                && getStep(tp, PieceActionEnum.FORWARDSLASH) == 2
                && !isBieJiao(tp)
                && !isCrossRiver(tp);
    }

    @Override
    public boolean simulateMove(Point tp) {
        return isMove(tp) && super.simulateMove(tp);
    }
}
